﻿using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
using Library;

namespace DirectoryWeb
{
  /// <summary>
  /// 共有フォルダーリスト画面のフォームです。
  /// </summary>
  public partial class VolumeList : Page
  {
    #region プライベートフィールド
    private Volume selectedFolder;
    #endregion

    #region イベントハンドラ
    protected void FolderDataSource_Selected(object sender, ObjectDataSourceStatusEventArgs e)
    {
      this.CountLabel.Text = String.Format("{0} 個のオブジェクト", ((ICollection)e.ReturnValue).Count);
    }

    protected void DetailDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
      if (this.FolderListBox.SelectedIndex == -1)
      {
        e.Cancel = true;
      }
    }

    protected void DetailDataSource_Selected(object sender, ObjectDataSourceStatusEventArgs e)
    {
      selectedFolder = (Volume)e.ReturnValue;
    }

    protected void DetailFormView_DataBound(object sender, EventArgs e)
    {
      if (this.FolderListBox.SelectedIndex >= 0)
      {
        var txt = (TextBox)this.DetailFormView.FindControl("KeywordTextBox");
        txt.Text = String.Join(Environment.NewLine, selectedFolder.Keywords);
      }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
      Response.Redirect("Main.aspx?idx=5");
    }
    #endregion
  }
}